<?php namespace App\Core\Service\Services;

trait Detailer{
    
    public $detailModel;
    
    public function detail(){
        $this->fireEvent('detailBeforeGet');
        try {
            $this->getRepository()->addCriteria($this->getIndexCriteria());
            $this->detailGetDeatil();
            if(empty($this->detailModel)){
                return $this->inputError();
            }
            $this->fireEvent('detailAfterGet');
            return $this->success($this->detailModel);
		} catch (\Exception $ex) {
            return $this->sysError($ex);
		}
    }
    
    protected function detailGetDeatil(){
        $this->detailModel = $this->getRepository()->first();
        return $this;
    }
}